﻿//CAROUSEL
$('.carousel').carousel({
       
        auto: true,
        period: 5000,
        duration: 500,
        effect: "fade",
        stop: true,
        markers: {
            type: "default"

        }
           
        });
//TAO LOGIN WINDOW
    $("#createFlatWindow").on('click', function () {
        $.Dialog({
            overlay: true,
            shadow: true,
            flat: true,
            title: 'Flat window',
            content: '',
            padding: 10,
            onShow: function (_dialog) {
                var content = '<form>' + '<label>Login</label>' + '<div class="input-control text"><input type="text" name="login"><button class="btn-clear"></button></div> ' +
                '<label>Password</label>' + '<div class="input-control password">  <input type="password" name="password">     <button class="btn-reveal"></button></div> ' +
                '<div class="input-control checkbox">      <label><input type="checkbox" name="c1" checked/>        <span class="check"></span>Check me out</label></div>' +
                 '<div class="form-actions">' +
                '<button class="button primary">Login to...</button> ' +
                '<button class="button" type="button" onclick="$.Dialog.close()">Cancel</button> ' +
                '</div>' +
                '</form>';
                $.Dialog.title("User login");
                $.Dialog.content(content);
                $.Metro.initInputs();
            }
        });
    });
//TAO EMBED WINDOW
    $("#createWindowYoutube").on('click', function () {
        $.Dialog({
            overlay: false,
            shadow: true,
            flat: false,
            icon: '<img src="images/excel2013icon.png">',
            title: 'KUNGFU PANDA 3D',
            content: '',
            onShow: function (_dialog) {
                var html = [
                    '<iframe width="640" height="480" src="//www.youtube.com/embed/PXi3Mv6KMzY" frameborder="0" allowfullscreen></iframe>'
                ].join("");

                $.Dialog.content(html);
            }
        });
    });
//BOOK GHE
    function checkout() {
        var body = document.getElementsByTagName('body')[0];
        var div = document.getElementById('check');
        var tbl = document.getElementsByTagName('table')[0];
        tbl.setAttribute('id', 'desk');
 
     
        var status = 0;
        var tbdy = document.createElement('tbody');
        var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        for (var i = 0; i < 5; i++) {
            var tr = document.createElement('tr');
            var nextChar = str.charAt(i);
            tr.innerHTML = nextChar
            for (var j = 0; j < 7; j++) {
                var td = document.createElement('td');
                td.setAttribute('class', 'seat');
                td.setAttribute('width', '60px');
                td.setAttribute('height', '65px');
                var z = j + 1;
               td.innerHTML = '<center>'+z+'</center>';    
               tr.appendChild(td);
            }
            tbdy.appendChild(tr);
        }
        tbl.appendChild(tbdy);
        div.appendChild(tbl);
    }
  

    function registerOnSeatClicked(cell) {
   
        cell.click(function () {
            cell.toggleClass('seat_choose');
            var chairs = document.getElementsByClassName('seat_choose');
            if (chairs.length <= 10) {
                var picked = "";
                 for (var i = 0; i < chairs.length; i++) {
                picked = chairs[i].innerText + picked;
                }
                var isPicked = document.getElementById('picked');
                isPicked.innerHTML = picked;
            } else { alert('enough'); cell.toggleClass('seat_choose'); }
            
        });
    }
    function addRowHandlers() {
        var table = document.getElementById("desk");

        for (i = 0; i < table.rows.length; i++) {
            for (j = 0; j < table.rows[i].cells.length; j++) {
                var cell = $(table.rows[i].cells[j]);

                registerOnSeatClicked(cell);
            };

        }
        
    }

//LUU TRANG THAI
   
    function getChair() {

    };

  
